package com.eat.fish_service.controller.web;

import com.eat.common_utils.R;
import com.eat.fish_service.service.DiseaseimgmoreService;
import com.eat.fish_service.service.FishNumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author CZF
 * @create 2022-05-01 14:56
 */

@RestController
@CrossOrigin
@RequestMapping("/web/index")
@Slf4j
@Api(tags = "web主页/可视化平台接口")
public class IndexController {

    @Autowired
    FishNumService fishNumService;

    @Autowired
    DiseaseimgmoreService diseaseimgmoreService;

    @ApiOperation("近期鱼数统计Echarts柱状图，参数1：鱼缸id；参数2：次数")
    @GetMapping("fishCountSta/{aquariumId}/{count}")
    public R fishCountSta(@PathVariable("aquariumId") Long aquariumId, @PathVariable("count") Integer count) {
        return fishNumService.fishCountSta(aquariumId, count);
    }

    @ApiOperation("鱼类占比echarts南丁格尔图,参数1：鱼缸id")
    @GetMapping("fishProportion/{aquariumId}")
    public R fishProportion(@PathVariable("aquariumId") Long aquariumId) {
        return fishNumService.fishProportion(aquariumId);
    }

    @ApiOperation("鱼状态echarts圆环图（良好、生病、死亡）,参数1：鱼缸id")
    @GetMapping("fishStateCircle/{aquariumId}")
    public R fishStateCircle(@PathVariable("aquariumId") Long aquariumId) {
        return fishNumService.fishStateCircle(aquariumId);
    }

    @ApiOperation("eplus组件progress进度条,参数1：鱼缸id")
    @GetMapping("fishProgress/{aquariumId}")
    public R fishProgress(@PathVariable("aquariumId") Long aquariumId) {
        return fishNumService.fishProgress(aquariumId);
    }

    @ApiOperation("一周鱼缸水质统计")
    @GetMapping("oneWeekWaterSta/{aquariumId}")
    public R oneWeekWaterSta(@PathVariable("aquariumId") Long aquariumId) {
        return fishNumService.oneWeekWaterSta(aquariumId);
    }

    //可视化页面的增减情况，
    @ApiOperation("可视化页面——增减情况，dayCount为最近多少次，一次为一天总的增减")
    @GetMapping("increaseAndDecrease/{aquariumId}/{dayCount}")
    public R increaseAndDecrease(@PathVariable("aquariumId") @ApiParam(name = "aquariumId",value = "鱼缸id",required = true) Long aquariumId,
                                 @PathVariable("dayCount") @ApiParam(name = "dayCount",value = "天数",required = true) Integer dayCount) {
        return fishNumService.increaseAndDecrease(aquariumId,dayCount);
    }

    @ApiOperation("查询更多鱼病图片")
    @GetMapping("getmoredisease/{diseaseName}")
    public R getmoredisease(@PathVariable("diseaseName") @ApiParam(name = "diseaseName",value = "鱼病名称",required = true) String diseaseName){
        return diseaseimgmoreService.getMoreDiseaseImg(diseaseName);
    }

}
